import { target_relation_remove_info } from '../Classes/cla_target_relation_remove_info';
import { get_db_relation_cur_meta_id } from './get_mdb';

export async function remove_relation_single(
  target_main: string,
  describe: string,
  target_num: string | string[]
) {
  if (typeof target_num == 'string') {
    target_num = [target_num];
  }

  for (const target_i_val of target_num) {
    await _remove_info(target_main, describe, target_i_val);
  }
}

// 单项 解除 绑定 信息
async function _remove_info(
  target_main: string,
  describe: string,
  target_num: string
) {
  let remove_relation_info = new target_relation_remove_info(
    describe,
    target_num
  );

  let db_relation_cur_target = get_db_relation_cur_meta_id(target_main);

  await db_relation_cur_target.deleteOne(remove_relation_info);
}
